<template>
    <div class=''>
        <h1>个人中心</h1>
        欢迎：{{$store.state.user}} 登录
        <p><button @click="exit">退出登录</button></p>
    </div>
</template>

<script>
export default {
    data() {
        return {};
    },
    mounted() {},
    methods: {
        exit(){
            this.$store.commit("exit")
            this.$router.push({path:"/login"})
        }
    },
    beforeRouteEnter (to, from, next) {
        next((vm)=>{
            if(vm.$store.state.user){
                next()
            }else{
                next("/login")
            }
        })
    }
};
</script>

<style lang='scss'>

</style>
